package com.fuhao.rabbit.direct;

import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.core.MessageListener;
import org.springframework.util.SerializationUtils;

import java.io.IOException;
import java.util.Map;

/**
 * @author zhang
 * @title: Comsumer1
 * @projectName spring-rabbit
 * @description: TODO
 * @date 2019/5/1921:41
 */
public class Comsumer1 implements MessageListener {
    private static final ObjectMapper MAPPER = new ObjectMapper();
    @Override
    public void onMessage(Message message) {
        JsonNode map = null;
        try {
            map = MAPPER.readTree(message.getBody());
        } catch (IOException e) {
            e.printStackTrace();
        }
        System.out.println("接收到消息："+map.get("name").asText());
    }
}
